<html>
<head>
    <meta charset="UTF-8">
    <meta name="csrf-token" content="{{ csrf_token() }}">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>@yield('title') - {{env('APP_NAME')}}</title>
    <link rel="shortcut icon" href="{{cdn('/assets/img/logo-2.png')}}" type="image/x-icon">
    <link rel="stylesheet" href="{{cdn('/assets/css/bootstrap/bootstrap.min.css')}}">
    <link rel="stylesheet" href="{{cdn('/assets/css/font-awesome.min.css')}}">
</head>
<body>
@include('include.alert')
<div style="width: 90%;margin: 30px 5% 10px 5%; ">
    <table class="table table-bordered">
        <thead>
        <tr>
            <th>ID</th>
            <th>用户</th>
            <th>权限组</th>
            <th>创建日期</th>
            <th>操作</th>
        </tr>
        </thead>
         @if (!empty($admins))
             @foreach($admins as $admin)
                 <tr>
                     <td>{{$admin->id or 0}}</td>
                     <td>{{$admin->name or ''}}</td>
                     <td>{{$admin->display_name or ''}}</td>
                     <td>{{$admin->created_at or ''}}</td>
                     <td>
                         <button class="btn btn-danger" onclick="deletePalatAdmin('{{$admin->mid or 0}}', this)">删除</button>
                     </td>
                 </tr>
             @endforeach
         @endif
        <tbody>
        </tbody>
    </table>
</div>
<div style="width: 50%;margin: 10px 25% 10px 25%;">
    <form action="{{url('/admin/mod/add')}}"  method="post" class="form-horizontal">
        {{csrf_field()}}
        <input type="hidden" name="plate_id" value="{{$plate_id or 0}}">
        <div class="form-group">
            <label for="select_tag" class="control-label text-success">类型名称</label>
            <select id="select_tag" class="form-control" name="users_id">
                @if (!empty($userAdmins))
                    <option disabled value="0" selected>请选择</option>
                    @foreach($userAdmins as $userAdmin)
                        <option value="{{$userAdmin->id or 0}}">{{$userAdmin->name or ''}}</option>
                    @endforeach
                @else
                    <option disabled value="=0">没有数据</option>
                @endif
            </select>
            <div class="form-group" style="margin-top: 10px; margin-left: 5px">
                <button type="submit" class="btn btn-success">添加</button>
            </div>
        </div>
    </form>
</div>
<script src="{{cdn('/supervise/assets/js/jquery-1.10.2.min.js')}}"></script>
<script src="{{cdn('/supervise/assets/js/jqueryui-1.10.3.min.js')}}"></script>
<script src="{{cdn('/supervise/assets/js/bootstrap.min.js')}}"></script>
<script>
    $(document).ready(function () {
        $('#select_tag').change(function () {
            $op = $(this).children('option:selected');
            $color = $op.attr('data-color');
            $(this).css('color', $color);
        });
    });
    function deletePalatAdmin($id, $this) {
        if ($id == 0){return}
        $.post('/admin/mod/del',{
            _token:$('meta[name="csrf-token"]').attr('content'),
            mid:$id
        }, function (data) {
            if (data.code == 0){
                $($this).parents('tr').remove();
            }else{
                alert('Error:'+data.code +' msg:'+data.msg);
            }
        })
    }
</script>
</body>
</html>